import { getcarModelDetail } from '@/api/carDetail'
import { getcarModelAtn } from '@/api/carDetail'
export default {
  state: {
    allcarModelMsg: {
      //如果是对象中的对象的话 {{allcarModelMsg.currentCar.name}}做渲染数据的时候 要在已定义的对象里面定义你要用的对象名
      cars: {},
      price: {},
      currentCar: {},
      pics: {},
      carSeries: {},
      parameters: [],
      atnMsg:{},
      isattention:"",
      isBid:"",
      isShare: ''
    },
  },
  getters:{
    allcarModelMsg(state){
        return state.allcarModelMsg
    }

  },
  actions: {
    //获取品牌数据 提交突变
    showCarDetails({commit},obj){

        // //console.log(obj)
        // //console.log("+++++++++++++++++++++++++++++++")
        getcarModelDetail(obj).then(resp => {
            //console.log(resp.data)
            // //console.log(resp.data)
            commit("GetCarDetails", resp.data)
            // //console.log(resp.data.pics)
        })
    },
    showAtn({commit}, obj) {
    //   //console.log(obj)
        getcarModelAtn(obj).then(resp => {
            // //console.log(resp);
            commit("getcarAtation", resp.data)
        })
    },
    choiseAtn({commit,state}){
       commit("changeAtn")
    }
  },
  mutations: { 
    GetCarDetails(state,data){
        state.allcarModelMsg=data
        state.isattention=data.isAttention
        state.isBid=data.isBid
        state.isShare = data.isShare
        //console.log(data)
    },
    getcarAtation(state,data){
        state.atnMsg=data;
        state.allcarModelMsg.isattention = data.value;

    },
    changeAtn(state){
        state.isattention=true
    }   
  }
}  